#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int n,m,l,v,t;
struct node{
    int v,a,d,dis,t;
}c[N];
bool cmp(node a,node b)
{
    return a.v<b.v;
}
int p[N],L[N*10];
bool which[N];
int read()
{
    int f=1,x=0;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    return f*x;
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--)
    {
        int ans=0,ans2=0;
        bool flag=0;
        memset(which,false,sizeof(which));
        memset(L,0,sizeof(L));
        n=read(),m=read(),l=read(),v=read();
        for(int i=1;i<=n;i++)
            c[i].d=read(),c[i].v=read(),c[i].a=read();
        for(int i=1;i<=m;i++)
            p[i]=read();
        for(int i=1;i<=n;i++)
            if(c[i].a!=0) flag=1;
        if(flag==0)
        {
            int maxn=-1;
            for(int i=1;i<=n;i++)
                maxn=max(maxn,c[i].v);
            if(maxn<=v)
            {
                cout<<0<<" "<<m<<endl;
            }
            else
            {
                maxn=-1;
                for(int i=1;i<=m;i++)
                    maxn=max(maxn,p[i]);
                sort(c+1,c+n+1,cmp);
                int lft=1,rgt=n;
                while(lft<rgt)
                {
                    int mid=(lft+rgt)/2;
                    if(c[mid].v>v) rgt=mid;
                    else lft=mid+1;
                }
                ans=n-lft;
                for(int i=lft;i<=n;i++)
                {
                    for(int j=1;j<=m;j++)
                    {
                        if(p[j]>=c[i].d)
                        {
                            which[j]=1;
                            break;
                        }
                    }
                }
                for(int i=1;i<=m;i++)
                if(which[i]==false) ans2++;
                cout<<ans<<" "<<ans2<<endl;
            }
        }
        else{
            for(int i=1;i<=n;i++)
            {
                for(int j=1;j<=m;j++)
                {
                    if(p[j]>=c[i].d)
                    {
                        c[i].dis=p[j]-c[i].d;
                        if(c[i].v*c[i].v-2*c[i].a*c[i].dis<0)
                            break;
                        c[i].t=(-1.0*c[i].v+sqrt(c[i].v*c[i].v-2*c[i].a*c[i].dis))/2;
                        if(sqrt(c[i].v*c[i].v+2*c[i].a*c[i].t)>v)
                        {
                            ans++;
                            which[j]=true;
                            break;
                        }
                    }
                }
            }
            for(int i=1;i<=m;i++)
                if(which[i]==false) ans2++;
            cout<<ans<<" "<<ans2+1<<endl;
        }
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
